﻿using Hhmocon.Mes.Repository;
using Hhmocon.Mes.Repository.Domain;
using Hhmocon.Mes.Repository.Repository;
using Hhmocon.Mes.Util;
using System;
namespace Hhmocon.Mes.Application
{
    /// <summary>
    /// app层除了 添加 的操作
    /// 删改查基本都可以由皮卡丘来做掉
    /// </summary>
    public class BaseCustomerApp
    {
        private IBaseCustomerRepository _baseCustomerRepository;
        private PikachuRepository _pikachuRepository;

        public BaseCustomerApp(IBaseCustomerRepository IBaseCustomerRepository, PikachuRepository pikachuRepository)
        {
            _baseCustomerRepository = IBaseCustomerRepository;
            _pikachuRepository = pikachuRepository;
        }


        /// <summary>
        /// 添加用户数据
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public base_customer InsertCustomer(base_customer data)
        {
            //取ID
            data.customer_id = CommonHelper.GetNextGUID();
            data.modified_time = Time.Now;
            data.create_time = DateTime.Now;
            if (_pikachuRepository.Insert(data))
            {
                return data;
            }
            else
            {
                return null;
            }
        }
    }
}
